package gui.components.JXTable;

import javax.swing.*;
import java.awt.*;
import java.awt.datatransfer.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.io.IOException;

/**
 * User: Programmer
 * Date: 30.01.2006
 * Time: 12:36:38
 */
public class mouseL extends MouseAdapter
{
    JTable table = null;

    public mouseL(JTable table)
    {
        this.table = table;
    }

    public void mousePressed(MouseEvent e)
    {
        if(e.getButton()==MouseEvent.BUTTON3){
            Toolkit tk = Toolkit.getDefaultToolkit();
            Clipboard cp = tk.getSystemClipboard();
            int y = table.getSelectedColumn();
            int x = table.getSelectedRow();
            String data = null;
            try
            {data = (String)cp.getContents(null).getTransferData(DataFlavor.stringFlavor);}
            catch (UnsupportedFlavorException e1)
            {e1.printStackTrace();}
            catch (IOException e1)
            {e1.printStackTrace();}
            table.getModel().setValueAt((data==null)?"":data,x,y);
        }
    }
}
